
Partial Class Secure_WebAdmin_MembershipDetails
    Inherits baseWebPage


    Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
        If Not User.IsInRole("WebAdmins") Then
            Response.Redirect("Default.aspx")
        End If
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If String.IsNullOrEmpty(Session("core_UserName")) Then
            Response.Redirect(MyBase.GetPreviousPage)
        End If
        hlBack.NavigateUrl = MyBase.GetPreviousPage
    End Sub

    Protected Friend Sub RoleAssigning(ByVal sender As Object, ByVal e As EventArgs)
        Dim checkbox As Web.UI.WebControls.CheckBox = CType(sender, CheckBox)
        Dim item As Web.UI.WebControls.GridViewRow = CType(checkbox.Parent.Parent, GridViewRow)
        Dim label As Label = CType(item.FindControl("RoleName"), Label)
        'Response.Write("Check box fires by " & label.Text & " Checked = " & checkbox.Checked & " for UserName = " & Session("core_UserName").ToString & "<br>")
        Dim userName As String = Session("core_UserName").ToString
        Dim roleName As String = label.Text
        If Not (String.IsNullOrEmpty(userName) OrElse String.IsNullOrEmpty(roleName)) Then
            If checkbox.Checked Then
                Roles.AddUserToRole(userName, roleName)
            Else
                Roles.RemoveUserFromRole(userName, roleName)
            End If
            gvRoles.DataBind()
        Else
            Response.Write("Is Empty UserName = " & String.IsNullOrEmpty(userName) & " <br/")
            Response.Write("Is Empty RoleName = " & String.IsNullOrEmpty(roleName) & " <br/")
        End If
    End Sub

End Class
